﻿<?php
	include '../inc/conn.php';
	
	session_start();	

	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);
	if (isset($act) && isset($id))
	{
		if ($act == "del"){
			$db = new mysql();
			$db->delete('eng_repo', "id=".$id);
			$db->close();
			echo "<script>alert('Data has deleted!!!');window.location='admin_index.php?name=repo';</script>";
		}
	}
?>
<div class="container-fluid">
<? if ($_SESSION['user'] != 1){  
	echo '<script>window.location="userinfo.php"</script>';
 } else {
?>
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">管理面板>>库存管控表</h3>
    </div>
    <div class="panel-body">
	<div>
		<table border=0 cellpadding=0 class="table table-striped">
		<tr class="success"><th>类型</th><th>料号</th><th>描述</th><th>数量</th><th>部门</th><th>保管人</th><th>状态</th><th>登记日期</th><th>更新日期</th><th>Admin</th></tr>
<?
		$db = new mysql();
		$db->query("select * from eng_repo ORDER BY KP_CHECKIN_DATE DESC");
		$num = $db->db_num_rows();
		for($i=0; $i<$num; $i++){
			$row = $db->fetch_assoc();
			$item = $i + 1;
			echo "			<tr>";
			switch($row['KP_TYPE']){
				case "整机":
					echo "<td><font color='#0000C6'>".htmlspecialchars_decode($row['KP_TYPE'])."</font></td>";
					break;
				case "电子":
					echo "<td><font color='#FF0080'>".htmlspecialchars_decode($row['KP_TYPE'])."</font></td>";
					break;	
				case "重材":
					echo "<td><font color='#006000'>".htmlspecialchars_decode($row['KP_TYPE'])."</font></td>";
					break;	
				case "机构":
					echo "<td><font color='#842B00'>".htmlspecialchars_decode($row['KP_TYPE'])."</font></td>";
					break;												
				case "主板":
					echo "<td><font color='#600000'>".htmlspecialchars_decode($row['KP_TYPE'])."</font></td>";
					break;
			}
			echo "<td>".htmlspecialchars_decode($row['KP_PN'])."</td>";
			echo "<td>".htmlspecialchars_decode($row['KP_DESC'])."</td>";
			echo "<td>".$row['KP_NUM']."</td>";
			echo "<td>".$row['DEPT']."</td>";
			echo "<td>".htmlspecialchars_decode($row['KP_OWNER'])."</td>";
			if ($row['STATUS'] == "借用中")
				echo "<td><font color='RED'>".htmlspecialchars_decode($row['STATUS'])."</font></td>";
			else
				echo "<td><font color='BLUE'>".htmlspecialchars_decode($row['STATUS'])."</font></td>";
			echo "<td>".substr(htmlspecialchars_decode($row['KP_CHECKIN_DATE']),0,10)."</td>";
			echo "<td>".substr(htmlspecialchars_decode($row['KP_CHECKOUT_DATE']),0,10)."</td>";
			echo "<td><a href=\"mod_repo.php?id=".$row['ID']."\" rel='tooltip' title='修改库存信息'><span class=\"glyphicon glyphicon-edit\"></span></a>";
			if (isset($_SESSION['admin']))
				echo "&nbsp;|&nbsp;<a href=\"admin_repo.php?id=".$row['ID']."&act=del\" rel='tooltip' title='删除表内容，当心哦~~~'><font color='red'><span class=\"glyphicon glyphicon-remove\"></span></font></a></td>";
			echo "</tr>\n";
		}
?>
		</table>
	</div>
</div>
</div>
</div>
<? 
}
	$db->close();
?>
